package com.itheima.dao;


import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.*;
//ibatis:MyBatis

import java.util.List;

public interface CheckItemDao {

    //queryString模糊查询（like）条件，可能代表code，也可能代表name。而且queryString有可能为null，也有可能不为null

    @Select("select * from t_checkitem where code like '%${queryString}%' or name like '%${queryString}%' ")
    List<CheckItem> findPage(@Param("queryString") String queryString);

    @Insert("insert into t_checkitem(code,name,sex,age,price,type,attention,remark) values(#{code},#{name},#{sex},#{age},#{price},#{type},#{attention},#{remark})")
    void add(CheckItem checkItem);

    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(int id);

    //冥想5分钟： 放空
    //中医（易经）
    //推背图
    @Update("update t_checkitem set code = #{code},name = #{name},sex = #{sex},age = #{age},price = #{price},type = #{type},attention = #{attention},remark = #{remark} where id = #{id}")
    void edit(CheckItem checkItem);

    @Delete("delete from t_checkgroup_checkitem where checkitem_id = #{id}")
    void deleteMid(int id);

    @Delete("delete from t_checkitem where id = #{id}")
    void deleteCheckItemById(int id);

    @Select("select * from t_checkitem")
    List<CheckItem> findAll();

    @Select("select * from t_checkitem where id in (select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{checkGroupId})")
    List<CheckItem> findCheckItemsByCheckGroupId(Integer checkGroupId);
}
